// src/main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
// import store from './vuex/store'
import store from '@/vuex/store'

import * as echarts from 'echarts'
import axios from 'axios'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import VueCookies from 'vue-cookies'

const app = createApp(App)

// 全局属性挂载
app.config.globalProperties.$echarts = echarts
app.config.globalProperties.$axios = axios
app.config.globalProperties.bus = app

const OriginalRO = window.ResizeObserver
window.ResizeObserver = class ResizeObserver {
  constructor(cb) {
    this._ro = new OriginalRO(entries => {
      try {
        cb(entries)
      } catch (err) {
        // 吞掉循环通知引发的错误
        if (!/ResizeObserver loop completed/.test(err.message)) {
          throw err
        }
      }
    })
  }
  observe(...args)   { return this._ro.observe(...args) }
  unobserve(...args) { return this._ro.unobserve(...args) }
  disconnect(...args){ return this._ro.disconnect(...args) }
}

// 插件注册
app.use(router)
app.use(store)
app.use(ElementPlus)
app.use(VueCookies)

app.mount('#app')